import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;

public class sample
{
    public static void main(String[] args ) throws InterruptedException
    {
    	System.setProperty("webdriver.ie.driver", "C:\\Users\\Sadaiyandi\\workspace1\\AutoUI\\src\\lib\\chromedriver.exe");
		WebDriver driver = new InternetExplorerDriver();
       // driver.get("http://www.w3schools.com/js/tryit.asp?filename=tryjs_alert");
        driver.get("http://www.w3schools.com/js/tryit.asp?filename=tryjs_confirm");
        
        driver.switchTo().frame(driver.findElement(By.id("iframeResult")));

        WebElement sign = driver.findElement(By.xpath("/html/body/button"));
        sign.click();
       
      /*  Set<String> windowId = driver.getWindowHandles();    // get  window id of current window
        for(String win:windowId)
        {
        	System.out.println(win);
        }*/
        
        /*
        Iterator<String> itererator = windowId.iterator();   

        String mainWinID = itererator.next();*/
        
        
        Alert a=driver.switchTo().alert();
       /* System.out.println(driver.getTitle());
        List<WebElement>  input= driver.findElements(By.tagName("input"));  
		for(int i=0;i<input.size();i++)
		{
			String id=input.get(i).getAttribute("id");
			String name=input.get(i).getAttribute("name");
		}*/
        System.out.println( a.getText());
       
        Thread.sleep(2000);
		a.accept();
        Thread.sleep(3000);
        

       // driver.switchTo().window(mainWinID);
        System.out.println(driver.getTitle());
        

       
        driver.close();
        driver.quit();
    }  
}